package cn.wolfcode.crm.mapper;

import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.query.EmployeeQueryObject;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface EmployeeMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Employee record);

    Employee selectByPrimaryKey(Long id);


    int updateByPrimaryKey(Employee record);

    List<Employee> query(EmployeeQueryObject qo);
    Integer count(EmployeeQueryObject qo);

    /**
     * 查询用户名的数量,判断是否存在
     *
     * @param username
     * @return
     */
    int validateName(String username);

    /**
     * 修改员工状态
     * @param id
     */
    void changeStateById(Long id);

    void updatePasswordById(@Param("id") Long id,
                            @Param("password")String password);

    /**
     * 关联角色
     * @param roleId
     * @param employeeId
     */
    void insertRelation(@Param("employeeId")Long employeeId,
                        @Param("roleId") Long roleId );
    void deleteRelation(Long employeeId);

    /**
     * 通过用户名查询员工角色
     * @param principal
     * @return
     */
    Employee slelectByUsernameInfo(String principal);

    List<Employee> selectAll();
}